Skip to content

Rust: Additional test cases for rust/weak-sensitive-data-hashing#22009

Open
geoffw0 wants to merge 4 commits into
github:mainfrom
geoffw0:rust-crypto
Open

Rust: Additional test cases for rust/weak-sensitive-data-hashing#22009
geoffw0 wants to merge 4 commits into
github:mainfrom
geoffw0:rust-crypto

Conversation

@geoffw0

@geoffw0 geoffw0 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Additional test cases for rust/weak-sensitive-data-hashing, based on investigation of some recent new results on DCA. There's a missing result (improvements possible here), and some near misses for false positive query results, but no actual false positive query results.

@geoffw0 geoffw0 added the no-change-note-required This PR does not need a change note label Jun 18, 2026
@geoffw0 geoffw0 requested a review from a team as a code owner June 18, 2026 22:44
@geoffw0 geoffw0 added the Rust Pull requests that update Rust code label Jun 18, 2026
Copilot AI review requested due to automatic review settings June 18, 2026 22:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds additional Rust query-test coverage for rust/weak-sensitive-data-hashing, based on recent DCA observations, and introduces a companion test run for the queries/summary/CryptographicOperations.ql summary query to validate the new/updated expectations in the same fixture.

Changes:

  • Expanded WeakSensitiveDataHashing test source with additional “near-miss” crypto API patterns (including local types named like algorithms and indirect hashing via a helper).
  • Updated inline expectations in test.rs to also assert rust/summary/cryptographic-operations results for relevant calls/constructors.
  • Added a new CryptographicOperations.qlref + expected output to run the summary query against the same test file.
Show a summary per file
File Description
rust/ql/test/query-tests/security/CWE-327/WeakSensitiveDataHashing/test.rs Adds new crypto-related test scenarios and updates inline expectations for both the security query and the summary query.
rust/ql/test/query-tests/security/CWE-327/WeakSensitiveDataHashing/WeakSensitiveDataHashing.expected Updates expected output to account for the newly-added indirect MD5 hashing case (generated test output update).
rust/ql/test/query-tests/security/CWE-327/WeakSensitiveDataHashing/CryptographicOperations.qlref Adds a new qlref to run the CryptographicOperations summary query with inline expectations postprocessing.
rust/ql/test/query-tests/security/CWE-327/WeakSensitiveDataHashing/CryptographicOperations.expected Adds expected output for the CryptographicOperations summary query (generated test output addition).

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 2

}

impl Seed {
fn new(seed_value: u64) -> Self {
Comment on lines +174 to +175
// this will be misrecognized as a use of the SEED algorithm, but being a strong
// algorithm and not sensitive data, there is no query result anyway.

fn sha1_test(password: &[u8]) {
let mut hasher = Sha1::new(); // $ Alert[rust/summary/cryptographic-operations]
hasher.update(password); // $ MISSING: Alert[rust/weak-sensitive-data-hashing]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this missing because we do not consider the parameter to be a source?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants